Skip to content

Conversation

Dt8333
Copy link
Contributor

@Dt8333 Dt8333 commented Oct 18, 2025

fixes #3063


Motivation / 动机

修复人格预设对话的重复注入问题。
修复人格预设对话_begin_dialogs_processed在执行过程中丢失属性_no_save的问题。

Modifications / 改动点

深拷贝Context做备份,避免供应商适配器移除Context内字段(_no_save)导致将预设会话存入历史。
深拷贝人格预设会话防止运行时被意外修改。

Verification Steps / 验证步骤

新建一个带有预设对话的人格。
进行对话,检查预设对话是否生效。
检查对话数据,里面应当不存在预设对话。

Screenshots or Test Results / 运行截图或测试结果

Compatibility & Breaking Changes / 兼容性与破坏性变更

  • 这是一个破坏性变更 (Breaking Change)。/ This is a breaking change.
  • 这不是一个破坏性变更。/ This is NOT a breaking change.

Checklist / 检查清单

  • 😊 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。/ If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
  • 👀 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。/ My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
  • 🤓 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到了 requirements.txtpyproject.toml 文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
  • 😮 我的更改没有引入恶意代码。/ My changes do not introduce malicious code.

Sourcery 总结

通过深拷贝对话上下文和预设消息,并在处理后恢复上下文,修复角色预设对话中的重复和属性丢失问题。

错误修复:

  • 在代理执行前后备份和恢复请求上下文,以防止角色预设对话被重复注入。
  • 深克隆角色 _begin_dialogs_processed 消息,以保留 _no_save 标志并避免意外的运行时变异。
Original summary in English

Summary by Sourcery

Fix duplication and property loss in persona preset dialogues by deep copying conversation contexts and preset messages and restoring contexts after processing

Bug Fixes:

  • Backup and restore request contexts around agent execution to prevent repeated injection of persona preset dialogues
  • Deep clone persona _begin_dialogs_processed messages to preserve _no_save flags and avoid unintended runtime mutations

备份Context避免供应商适配器移除Context内字段导致将预设会话存入历史。深拷贝人格预设会话防止运行时被意外修改。

AstrBotDevs#3063
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你好 - 我已审阅了你的更改,它们看起来很棒!


Sourcery 对开源项目免费 - 如果你喜欢我们的评论,请考虑分享它们 ✨
帮助我更有用!请在每条评论上点击 👍 或 👎,我将利用反馈来改进你的审阅。
Original comment in English

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Soulter Soulter merged commit 361d782 into AstrBotDevs:master Oct 19, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]人格预设对话会随着对话次数的增加重复注入

2 participants